docs(patterns): on-chain / off-chain boundary guide + feat(design-system): shared versioned tokens package - #289
Merged
salazarsebas merged 2 commits intoAug 15, 2026
Conversation
Adds docs/ONCHAIN_OFFCHAIN_BOUNDARY.md, the guide recommended in docs/strategy/04-onchain-gaming-research.md problem salazarsebas#1 and listed as the second-priority Learn-section gap in the documentation architecture. The guide gives a five-question framework for placing a single piece of game state or logic, then works it through three shipped examples: battleship (commitments on-chain, placement and Merkle tree off-chain), snake (a full on-chain simulation that is turn-based rather than real-time, stated honestly), and blind_auction (a proof standing in for data, with the Experimental maturity of Groth16 verification named). Every claim is drawn from the current source of the example it describes, including the shortcuts: battleship does not validate fleet legality, and snake has no authorization and derives food placement from the tick counter. It closes with an explicit list of what Soroban throughput cannot support, so the guide does not imply on-chain real-time gameplay is achievable. Resource cost and privacy tiers are cross-linked to PERFORMANCE.md and PRIVACY_MODEL.md rather than re-derived, and the Phase 2 GameHarness resource-reporting work is referenced as planned rather than available. Linked from the README documentation list, the PATTERNS.md problem table, and a Related section in PERFORMANCE.md.
|
@Spagero763 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
Owner
|
The on-chain/off-chain boundary guide (#251) is thorough and reads well. For the tokens package (#260): could you drop |
Adds packages/tokens (cougr-tokens), a versioned artifact encoding every value defined in docs/BRAND.md so the documentation site and the showcase consume one source instead of hand-copying values. Format decision: tokens.json is the single hand-edited source, and a zero-dependency build script emits both dist/tokens.css and dist/tokens.js. CSS custom properties alone are not sufficient because some consumers need literal values at generation time: anything producing a standalone artifact is consumed outside a document, so custom properties declared by a host page never reach it. Both outputs come from the same build, so they cannot disagree. dist/ is generated, not committed. It is built by npm run build, and by the prepare script on install and before pack/publish, so an installing consumer gets built output without running the build and nothing in git can fall out of step with the source. Because there is no committed dist/ to diff against, --check no longer compares build output. It now validates the source and a dry-run build, and fails when tokens.json has drifted from docs/BRAND.md. That moves the guarantee to where the risk actually is: BRAND.md is the declared source of truth and nothing otherwise stops the two being edited apart. Light and dark sets are complete for every themed token. Light is the default on :root, dark applies under prefers-color-scheme unless the document opts out, and an explicit data-theme attribute on the root element always wins. Adds a path-filtered Design Tokens workflow that runs the drift check, builds, loads the built module to confirm both modes resolve, and asserts dist/ is not tracked.
Spagero763
force-pushed
the
docs/boundary-guide-and-design-tokens
branch
from
July 30, 2026 07:40
512d98a to
a1f6870
Compare
Contributor
Author
|
@salazarsebas kindly review and merge |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #251
Part of #260
Updated per review: build output is no longer committed, and the showcase integration has moved to its own PR. The commits are still split one per issue.
Changes since the first round
packages/tokens/dist/is gitignored and gone from the diff. It is built bynpm run build, and automatically by apreparescript on install and beforenpm pack/npm publish, so an installing consumer still gets built output without running the build.Design Tokensworkflow that verifies, builds, loads the built module to confirm both modes resolve, and fails ifdist/ever becomes tracked.tools/preview-genisn't part of thisOne consequence worth calling out
build.js --checkused to diff the committeddist/against a fresh build. With nothing committed to diff, that check would be vacuous in a clean clone, so it now guards the drift that actually remains:tokens.jsonagainstdocs/BRAND.md, which is the declared source of truth and the one pair nothing else stops being edited apart.Verified it catches both a changed color and a changed scale value, and passes on a clean tree with no
dist/present.1. On-chain / off-chain boundary guide (#251)
Unchanged from the first round. New
docs/ONCHAIN_OFFCHAIN_BOUNDARY.md, the filename recommended indocs/strategy/04-onchain-gaming-research.mdproblem #1.A five-question framework for placing one piece of game state or logic at a time, then three worked examples written against the current source rather than an idealized version:
battleshipreveal_cellactually closes throughleaf_hashandSha256MerkleProofVerifier.snakeblind_auctionsealed_bidbinds the reveal to the auction ID andmax_bidin the same verification.Per the definition of done, the guide names the shortcuts the source review turned up rather than writing around them:
battleshipverifies a revealed cell against the commitment but never checks the committed board is a legal fleet, andsnakehas norequire_authanywhere insrc/and derives food placement from the tick counter. It also states plainly what Soroban throughput cannot support, and cross-linksPERFORMANCE.mdandPRIVACY_MODEL.mdrather than restating them.The definition of done asks for publication in the docs site's Learn section linked from the tutorial's next steps. The scaffold (#249) and tutorial (#250) have not landed, so the guide sits in
docs/and is linked from the README documentation list, thePATTERNS.mdproblem table, and a new Related section inPERFORMANCE.md. It slots into Learn unchanged when #249 lands.2. Shared, versioned tokens package (Part of #260)
packages/tokens(cougr-tokensv1.0.0) encodes every value indocs/BRAND.md: four neutrals, primary and accent, three maturity-tier colors, two font stacks, the eight-step spacing scale, four radii, and the four fixed logo tones. Verified mechanically that nothing inBRAND.mdis missing and no color was invented.Format decision.
tokens.jsonis the single hand-edited source; a zero-dependencybuild.jsemits bothdist/tokens.cssanddist/tokens.js. CSS custom properties alone are preferable unless there is a build-time transform need, and there is one: anything producing a standalone artifact (an SVG, a PNG, terminal output) is consumed outside a document, so custom properties declared by a host page never resolve. Both outputs come from the same build and cannot disagree.Style Dictionary was considered and skipped: it would add a dependency and a toolchain to a repository whose only other Node tool is deliberately install-free, for a transform that is about forty lines.
Theming. Light and dark are complete for every themed token. Light is the default on
:root, dark applies underprefers-color-schemeunless the document opts out withdata-theme="light", and an explicitdata-themeon the root element always wins.Versioning. Semver against the token surface rather than the code, with bump rules and the change procedure in the package README and a
CHANGELOG.md. Each consumer pins its own range, so one can upgrade ahead of the other and the divergence is a fact in a lockfile rather than something noticed by eye.docs/BRAND.mdhad a line saying a code package was out of scope and tracked separately; it now points at the package and restates thatBRAND.mdremains the source of truth.Why this says "Part of #260" rather than "Closes"
#260's definition of done has two items. This PR ships the first (a versioned package with light and dark values for every token). The second is "at least one real site/build consumes it and visibly reflects a token change when the package is updated" — that was what the
tools/preview-genintegration was doing here, since the docs-site scaffold (#249) hasn't landed and the showcase generator was the only real consumer available.Splitting it out is fine, but it does mean #260 shouldn't auto-close on this PR with its second item outstanding. So the follow-up carries
Closes #260, and this one carriesPart of #260. Say the word if you'd rather this PR close it and the follow-up just reference it.Follow-up PR
The showcase integration is now #291, stacked on this branch. It converts the four preview renderers from their hand-copied slate palettes to the shared tokens and includes the regenerated previews, which is the end-to-end proof for #260's second item. It also handles the consequence of un-committing
dist/:generate.jsbuilds the tokens on first run, sonode generate.js <game>still works from a fresh clone with no setup step.It is stacked, so it will show only its own diff once this merges. Happy to reorder if you'd rather review them the other way round.
Validation
node build.jsandnode build.js --check, both clean, including--checkon a tree with nodist/present.tokens.json: both fail with a specific message, and pass again when reverted.docs/BRAND.mdagainsttokens.json: none missing, none added.cargo fmt --checkclean. No Rust source is touched, so Core CI's path filter does not select this PR.On the rebase
mainis still atbe4f2f2("feat(cli): implement 'cougr new' project generator", 2026-07-27), and this branch was already based directly on it, so there was nothing to rebase onto. I re-fetched and confirmed against the API rather than assume. The force-push above is the restructuring, not a rebase. If you were expecting newer commits onmain, something may not have landed yet, and I'll rebase as soon as it does.Notes for review
docs/strategy/12-documentation-architecture.mdthat still mark the boundary guide and design tokens as gaps. Those read as point-in-time analysis documents, so I left them alone; happy to update them if you would rather they track shipped state.